package cn.wl.shiro.util;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;

public class MyHashedCredentialsMatcher extends HashedCredentialsMatcher {
    //密码匹配器的方法 login(token)
    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        MyUsernamePasswordToken myToken = (MyUsernamePasswordToken) token;
        //如果是免密登录 放行
        if(myToken.getLoginType().equals(LoginType.NOPASSWORD)){
            return true;
        }else {
            return super.doCredentialsMatch(token, info);
        }
    }
}
